<template>
  <div class="form_box">
    <avue-form :option="option" v-model="crudData.form" @submit="handleSubmit">
    </avue-form>
  </div>
</template>
<script setup>
import {configList, configPut} from "@/api/user/index.js";
import {ElMessage} from "element-plus";
import {onMounted} from "vue";

let props = defineProps({
  content: {
    type: Object,
    default: () => [],
    required: true
  }
})
const crudData = reactive({
  form: {},
  nowData: {},
})
const option = reactive({
  labelWidth: 200,
  size: 'medium',
  column: [
    {
      label: '用户Usdt唯一',
      prop: 'user_usdt_unique',
      type: 'switch',
      dicData: [{
        label: '',
        value: '0'
      }, {
        label: '',
        value: '1'
      }],
      span: 24,
    },
    {
      label: '最小充值金额',
      prop: 'minimum_recharge_amount',
      span: 24,
      prefixIcon: 'el-icon-edit',
      rules: [
        {
          required: true,
          message: '请输入最小充值金额',
          trigger: 'blur',
        },
      ],
    },
    {
      label: '最大充值金额',
      prop: 'maximum_recharge_amount',
      span: 24,
      prefixIcon: 'el-icon-edit',
      rules: [
        {
          required: true,
          message: '请输入最大充值金额',
          trigger: 'blur',
        },
      ],
    },
    {
      label: '最小提现金额',
      prop: 'minimum_withdrawal_amount',
      span: 24,
      prefixIcon: 'el-icon-edit',
      rules: [
        {
          required: true,
          message: '请输入最小提现金额',
          trigger: 'blur',
        },
      ],
    },
    {
      label: '最大提现金额',
      prop: 'maximum_withdrawal_amount',
      prefixIcon: 'el-icon-edit',
      span: 24,
      rules: [
        {
          required: true,
          message: '请输入最大提现金额',
          trigger: 'blur',
        },
      ],
    },
  ]
})
const handleSubmit = (form, done) => {
  let params = {}
  params.withdrawal = form
  console.log('form', params)
  configPut(params).then(res => {
    ElMessage.success('操作成功')
    initData()
  }).catch(err => {
  })
  done()
}
const initData = async () => {
  await configList().then(res => {
    crudData.form = res.data.withdrawal
  })
}
onMounted(() => {
  initData()
})
</script>
<style scoped lang="scss">
.form_box {
  width: 100%;
  padding: 0 20px 20px 20px;
  height: calc(100vh - 120px);
  overflow-y: auto;

  ::v-deep .avue-form {
    .el-collapse-item__wrap {
      padding: 20px;
    }
  }
}
</style>
